package com.hogae.capital.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hogae.core.annotation.Log;
import com.hogae.core.core.controller.BaseController;
import com.hogae.core.core.domain.AjaxResult;
import com.hogae.core.enums.BusinessType;
import com.hogae.core.utils.poi.ExcelUtil;

import com.hogae.capital.domain.CapAccountRecord;
import com.hogae.capital.service.ICapAccountRecordService;
import com.hogae.core.core.page.TableDataInfo;

/**
 * 资金账户明细Controller
 *
 * @author hogae
 * @date 2021-02-26
 */
@Api(tags = "资金账户明细")
@RestController
@RequestMapping("/capital/capAccountRecord")
public class CapAccountRecordController extends BaseController {
    @Autowired
    private ICapAccountRecordService capAccountRecordService;

    /**
     * 查询资金账户明细列表
     */
    @ApiOperation("查询资金账户明细列表")
    @PreAuthorize("@ss.hasPermi('capital:capAccountRecord:list')")
    @GetMapping(value = "/list", produces = MediaType.APPLICATION_JSON_VALUE)
    public TableDataInfo list(CapAccountRecord capAccountRecord) {
        startPage();
        List<CapAccountRecord> list = capAccountRecordService.selectCapAccountRecordList(capAccountRecord);
        return getDataTable(list);
    }

    /**
     * 导出资金账户明细列表
     */
    @ApiOperation("导出资金账户明细列表")
    @PreAuthorize("@ss.hasPermi('capital:capAccountRecord:export')")
    @Log(title = "资金账户明细", businessType = BusinessType.EXPORT)
    @GetMapping(value = "/export", produces = MediaType.APPLICATION_JSON_VALUE)
    public AjaxResult export(CapAccountRecord capAccountRecord) {
        List<CapAccountRecord> list = capAccountRecordService.selectCapAccountRecordList(capAccountRecord);
        ExcelUtil<CapAccountRecord> util = new ExcelUtil<CapAccountRecord>(CapAccountRecord.class);
        return util.exportExcel(list, "capAccountRecord");
    }

    /**
     * 获取资金账户明细详细信息
     */
    @ApiOperation("获取资金账户明细详细信息")
    @PreAuthorize("@ss.hasPermi('capital:capAccountRecord:query')")
    @GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(capAccountRecordService.selectCapAccountRecordById(id));
    }

    /**
     * 新增资金账户明细
     */
    @ApiOperation("新增资金账户明细")
    @PreAuthorize("@ss.hasPermi('capital:capAccountRecord:add')")
    @Log(title = "资金账户明细", businessType = BusinessType.INSERT)
    @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
    public AjaxResult add(@RequestBody CapAccountRecord capAccountRecord) {
        return toAjax(capAccountRecordService.insertCapAccountRecord(capAccountRecord));
    }

    /**
     * 修改资金账户明细
     */
    @ApiOperation("修改资金账户明细")
    @PreAuthorize("@ss.hasPermi('capital:capAccountRecord:edit')")
    @Log(title = "资金账户明细", businessType = BusinessType.UPDATE)
    @PutMapping(produces = MediaType.APPLICATION_JSON_VALUE)
    public AjaxResult edit(@RequestBody CapAccountRecord capAccountRecord) {
        return toAjax(capAccountRecordService.updateCapAccountRecord(capAccountRecord));
    }

    /**
     * 删除资金账户明细
     */
    @ApiOperation("删除资金账户明细")
    @PreAuthorize("@ss.hasPermi('capital:capAccountRecord:remove')")
    @Log(title = "资金账户明细", businessType = BusinessType.DELETE)
    @DeleteMapping(value = "/{ids}", produces = MediaType.APPLICATION_JSON_VALUE)
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(capAccountRecordService.deleteCapAccountRecordByIds(ids));
    }
}
